<template>
    <div id="home">
        <div id="back">
            <topBar :isNotLogIn="isNotLogIn" :userName="userName"></topBar>
            <router-view></router-view>
        </div>
        <bottomBar></bottomBar>
    </div>
</template>
<script>
import topBar from '@/components/common/topBar'
import bottomBar from '@/components/common/bottomBar'
export default {
  data () {
    return {
      isNotLogIn: true,
      userName: ''
    }
  },
  created () {
    this.getParams()
  },
  watch: {
    '$route.path': 'getParams'
  },
  methods: {
    // 接收用户名和登录状态
    getParams () {
      const res = JSON.parse(window.sessionStorage.getItem('user'))
      if (res === null) return
      this.userName = res.userName
      this.isNotLogIn = false
    }
  },
  components: {
    topBar,
    bottomBar
  }
}
</script>
<style scoped>
#home {
    height: 100%;
    width: 100%;
}
#back {
    height: 95%;
    width: 100%;
}
</style>
